package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.AirTicket;
import cn.wolfcode.luowowo.article.domain.AirTicketOrder;
import cn.wolfcode.luowowo.article.mapper.AirTicketMapper;
import cn.wolfcode.luowowo.article.mapper.AirTicketOrderMapper;
import cn.wolfcode.luowowo.article.service.IAirTicketService;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class AirTicketServiceImpl implements IAirTicketService{
    @Autowired
    private AirTicketMapper airTicketMapper;

    @Autowired
    private AirTicketOrderMapper airTicketOrderMapper;



    @Override
    public List<AirTicket> search(String orgCity, String dstCity, String depTime) {
        return airTicketMapper.search(orgCity, dstCity, depTime);
    }

    public void saveOrder(Long id, UserInfo userInfo) {
        AirTicketOrder order = new AirTicketOrder();
        order.setOrdernum("1");
        order.setCreatime(new Date());
        order.setAirticket(airTicketMapper.selectByPrimaryKey(id));
        order.setUser(userInfo);
        airTicketOrderMapper.insert(order);
    }

    public AirTicket getById(Long id) {
        AirTicket airTicket = airTicketMapper.selectByPrimaryKey(id);
        return airTicket;
    }

}
